package com.example.administrator.beepdemo;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.cbtService.AndroidSDK.BeepService;


public class MainActivity extends AppCompatActivity implements View.OnClickListener{
    Button btStart,btStop,btAdd,btSub;
    int i = 100;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        BeepService._init();
        btStart=(Button)findViewById(R.id.button);
        btStop=(Button)findViewById(R.id.button2);
        btAdd=(Button)findViewById(R.id.button3);
        btSub=(Button)findViewById(R.id.button4);
        btStart.setOnClickListener(this);
        btStop.setOnClickListener(this);
        btAdd.setOnClickListener(this);
        btSub.setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {
    switch (v.getId()) {
        case R.id.button:
            BeepService.PWMPlay(i);
            break;
        case R.id.button2:
            BeepService.PWMStop();
            break;
        case R.id.button3:
            i = i + 10;
            BeepService.PWMPlay(i);
            break;
        case R.id.button4:
            i = i - 10;
            BeepService.PWMPlay(i);
            break;
    }
    }
}
